home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / lib / user / lastusergroup.c < prev    next >
C/C++ Source or Header  |  1996-07-18  |  538b  |  23 lines

  1. #include "user.p"
  2.  
  3. int lastusergroup(int gi)
  4. {
  5.     USER_
  6.     *up;
  7.     unsigned
  8.     idx;
  9.  
  10.     up = &user[nusers - 1];                 /* points to last user */
  11.  
  12.     for (idx = 0; idx < up->ngroups; idx++)
  13.     {
  14.     if (up->groups[idx] == gi)        /* group already exists ? */
  15.         return (0);                /* then done */
  16.     }
  17.                         /* store the new group-index */
  18.     up->groups = xrealloc(up->groups, (++up->ngroups) * sizeof(unsigned));
  19.     up->groups[idx] = gi;            /* store the new groupindex */
  20.  
  21.     return (1);                    /* its's a new group */
  22. }
  23.